package br.elsa.survey.domain.questions;

import javax.enterprise.inject.Produces;

import br.elsa.survey.domain.qualifiers.NewEntity;

/**
 * Factory for {@link Question} entities
 * 
 * <p>
 * Questions can be:
 * 
 * <ol>
 * <li>{@link RadioQuestion}</li>
 * <li>{@link CheckboxQuestion}</li>
 * <li>{@link DiscursiveQuestion}</li>
 * </ol>
 * </p>
 * 
 * @author diego
 * 
 */
public class QuestionsFactory {

	/**
	 * Creates a {@link CheckboxQuestion} instance.
	 * 
	 * <p>
	 * This instance is initialized with a new empty choice.
	 * </p>
	 * 
	 * @return an instance of {@link CheckboxQuestion}
	 */
	public @Produces
	@NewEntity
	CheckboxQuestion createCheckboxQuestion() {

		CheckboxQuestion question = new CheckboxQuestion();
		question.createNewEmptyOption();
		question.setLevel(Level.None);
		question.setNullableAnswer(false);
		question.setMinNumberChosenOptions(1);

		return question;
	}

	/**
	 * Creates a {@link RadioQuestion} instance.
	 * 
	 * <p>
	 * This instance is initialized with a new empty choice.
	 * </p>
	 * 
	 * @return an instance of {@link RadioQuestion}
	 */
	public @Produces
	@NewEntity
	RadioQuestion createRadioQuestion() {

		RadioQuestion question = new RadioQuestion();
		question.createNewEmptyOption();
		question.setLevel(Level.None);
		question.setNullableAnswer(false);

		return question;
	}

	/**
	 * Creates a {@link DiscursiveQuestion} instance.
	 * 
	 * <p>
	 * This instance is initialized with a new empty choice.
	 * </p>
	 * 
	 * @return an instance of {@link DiscursiveQuestion}
	 */
	public @Produces
	@NewEntity
	DiscursiveQuestion createDiscursiveQuestion() {

		DiscursiveQuestion question = new DiscursiveQuestion();
		question.setLevel(Level.None);
		question.setEmptyAnswerEnabled(false);

		return question;
	}
}
